package com.kuang.swagger.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket1(Environment environment){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("a");

    }
    @Bean
    public Docket docket2(Environment environment) {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("b");
    }
    @Bean
    public Docket docket3(Environment environment) {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("c");
    }
    @Bean
    public Docket docket(Environment environment){
        Profiles of = Profiles.of("dev", "test");
        boolean b = environment.acceptsProfiles(of);
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("林东")
                .enable( b)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.kuang.swagger.controller"))
//                .paths(PathSelectors.ant("/kuang/**"))
                .build();

    }
    private ApiInfo apiInfo(){
        Contact contact = new Contact("林东松", "http://baidu.com", "869285457@qq.com");
        return new ApiInfo(
                "林东松学习swagger",
                "林东松是个帅哥",
                "v1.0",
                "http://terms.service.url",
                contact,
                "Apach2.0许可",
                "许可链接",
                new ArrayList<>()

        );
    }

}
